<template>
    <div>user info {{ props.userInfo }}<button @click="chatWith">chat!</button></div>
</template>
<script setup lang="ts">
import type { Relationship } from '@/types';
import chatUserApi from '@/api/chatUser'
const props = defineProps<{
    userInfo:Relationship
}>()
const emit = defineEmits<{
    (ev:'chatWith',friendName:Relationship):void
}>()
const chatWith = () => {
    chatUserApi.beginNewChat(props.userInfo.id).then(res => {
        if(res.data.code == '200') {
            emit('chatWith',props.userInfo)
        }
    })
   
}
</script>
<style scoped>

</style>